﻿@{
    ViewBag.Title = "授权记录";
}

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="~/Scripts/css/test.css" rel="stylesheet" />
<script src="~/Scripts/js/JQ.js"></script>
<script src="~/Scripts/global.js"></script>
<link href="~/Content/bootstrap/css/style.css" rel="stylesheet" />
<link href="~/Content/bootstrap/css/base.css" rel="stylesheet" />
<script src="~/Scripts/jquery-2.1.1.min.js"></script>
<script src="~/Scripts/layer/layer.js"></script>
<script src="~/Scripts/Common.js"></script>
<script src="~/Scripts/layPage/laypage.js"></script>
<link href="~/Scripts/css/gloabcss.css" rel="stylesheet" />
<style>
    input {
        height: 25px;
        margin-left: 15px;
    }

    .span8 input {
        width: 30%;
    }

    .container-fluid {
        margin: 0;
        padding: 0;
    }

    #edit_agency p {
        padding-top: 15px;
    }

    table tr td {
        padding: 12px 0px 12px 0px;
    }

    #Paging {
        position: absolute;
        float: right;
        left: 60%;
        margin-top: 4%;
    }
</style>
<script>
    document.onkeydown = function (event) {
       var e = event || window.event || arguments.callee.caller.arguments[0];
       if (e && e.keyCode == 27) { // 按 Esc 
           $(".layui-layer-close").click();
       }

   };
    var hiden_type = 1;
    var id = 0;
    //窗体加载
    $(function () {
        id = getUrlParam("agency_id")
        SearchList();
    })
    
    //模糊查询
    function queryauthorization(pageindex, pagesize) {

        var pagecount;
        $.ajax({
            type: "GET",
            url: "/Authorization/query_authorization",
            data: { "pageindex": pageindex, "pagesize": pagesize, "id": id },
            dataType: "json",
            async: false,
            success: function (data) {
                $("#tab_product  tr:not(:first)").remove();
                if (data.MessageCode == "0") {
                    //layer.alert(JSON.stringify(data));
                    pagecount = data.Pagecount;
                    if (data.AuthorizationList != null) {
                            $.each(data.AuthorizationList, function (i, n) {

                                var html = "<tr class='rep-tab-tr1 back-f9f'>" +
                                    "<td>" + n.id + "</td>" +
                                    "<td>" + n.AgencyName + "</td>" +
                                    "<td>" + formatDateTime(n.start_time) + "</td>" +
                                    "<td>" + formatDateTime(n.end_time) + "</td>" +
                                      "<td>" + formatDateTime(n.time) + "</td></tr>"
                                $("#tab_product").append(html);
                        
                            });
                       
                    } else {
                        layer.msg("暂无数据");
                    }
                } else {
                    layer.msg("查询失败，请稍后再试！");
                }
            }
        })
        return pagecount;
    }


    //分页
    function SearchList() {
        var pagecount = queryauthorization(1, 8);
        //好像很实用的样子，后端的同学再也不用写分页逻辑了。
        laypage({
            cont: 'pager',
            pages: pagecount, //可以叫服务端把总页数放在某一个隐藏域，再获取。假设我们获取到的是18
            skip: true, //是否开启跳页
            skin: '#5c86b2',
            curr: function () { //通过url获取当前页，也可以同上（pages）方式获取
                var page = location.search.match(/page=(\d+)/);
                return page ? page[1] : 1;
            }(),
            jump: function (e, first) { //触发分页后的回调
                if (e.pages > 1) { $('#pagercount').html('共' + e.pages + '页'); } else { $('#pagercount').hide(); }
                $('.laypage_skip').val(e.curr);
                if (!first) { //一定要加此判断，否则初始时会无限刷新
                    queryauthorization(e.curr, 8);
                }
            }
        });
    }
</script>
<div class="rightoverflow">
    <div class="ove-hid">
        <div class="wid-120 cor-4d4 fon-siz20 lin-hei60 bor-botdcd ">
            <label style="font-weight:bold;">当前授权信息：</label>
            <div style=" margin-left:2%;">
                <p>
                    授权时间(始):&nbsp;@{
                        if (@Model.start_time != null)
                        {
                            @Model.start_time.ToString("yyy-MM-dd mm:HH:ss")
                        }
                        else { 
                          <label></label>
                        }   
                    }
                </p>
                <p>
                    授权时间(止):&nbsp;@{
                        if (@Model.end_time != null)
                        {
                            @Model.end_time.ToString("yyy-MM-dd mm:HH:ss")
                        }
                        else
                        {
                            <label></label>
                        }
                    }</p>
            </div>
        </div>
    </div>

    <div class="ove-hid">
        <div class="Rep-main wid-100 mag-top50">
            <label style="font-weight:bold;">历史记录</label>
                     <div class="pro-div" id="con_two_1">
                <table class="rep-tab wid-100 cor-4d4 tex-ali" id="tab_product">
                    <thead>
                        <tr>
                            <td>id</td>
                            <td>用户名称</td>
                            <td>授权时间(始)</td>
                            <td>授权时间(止)</td>
                            <td>添加时间</td>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
</div>
<div id="Paging">
    <span id="pagercount" style="float:left "></span>
    <div id="pager" class="pager" style="float:left">
    </div>
</div>


